//
//  PKHomeViewControllerTweetCell.swift
//  Panku
//
//  Created by mac on 2017/5/28.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import SVProgressHUD

class PKHomeViewControllerTweetCell: PKBaseTableViewCell {

    //MARK: - UI
    lazy var avatarView = UIImageView()
    lazy var originLabel = UILabel()
    lazy var titleLabel = UILabel()
    lazy var descLabel = UILabel()
    
    lazy var thumbUpCountLabel = UILabel()
    lazy var commentCountLabel = UILabel()
    lazy var shareButton = PKBaseButton.createButton()
    
    override func setupCell() {
        contentView.addSubview(avatarView)
        contentView.addSubview(originLabel)
        contentView.addSubview(titleLabel)
        contentView.addSubview(descLabel)
        contentView.addSubview(thumbUpCountLabel)
        contentView.addSubview(commentCountLabel)
        contentView.addSubview(shareButton)
        
        avatarView.image = R.image.mine_logo()
        avatarView.layer.cornerRadius = 15
        avatarView.layer.masksToBounds = true
        avatarView.backgroundColor = UIColor.lightGray
        
        originLabel.text = "来自话题: 设计"
        originLabel.textColor = UIColor(hexString: "999999")
        originLabel.font = UIFont.PKFont(Size: 16)
        
        titleLabel.text = "你用过，见过那些[奇怪]的东西?"
        titleLabel.textColor = UIColor(hexString: "5D5D5D")
        titleLabel.font = UIFont.PKFont(Size: 18)
        
        descLabel.numberOfLines = 0
        
        descLabel.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"
        
        descLabel.textColor = UIColor(hexString: "AEAEAE")
        descLabel.font = UIFont.PKFont(Size: 14)
        
        thumbUpCountLabel.text = "477 赞同"
        thumbUpCountLabel.textColor = UIColor(hexString: "A1A1A1")
        thumbUpCountLabel.font = UIFont.PKFont(Size: 15)
        
        commentCountLabel.text = "103 评论"
        commentCountLabel.textColor = UIColor(hexString: "A1A1A1")
        commentCountLabel.font = UIFont.PKFont(Size: 15)
        
        shareButton.setTitle("分享", for: .normal)
        shareButton.setTitleColor(UIColor(hexString: "A1A1A1"), for: .normal)
        shareButton.titleLabel?.font = UIFont.PKFont(Size: 15)
        shareButton.addBlock(for: .touchUpInside) { (_) in
            //点击了分享
            SVProgressHUD.showInfo(withStatus: "点击了分享按钮")
        }
        
        avatarView.snp.makeConstraints { (make) in
            make.top.equalTo(contentView.snp.top).offset(6)
            make.left.equalTo(contentView.snp.left).offset(12)
            make.width.equalTo(30)
            make.height.equalTo(30)
        }
        
        originLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(avatarView.snp.centerY)
            make.left.equalTo(avatarView.snp.right).offset(5)
            make.right.equalTo(contentView.snp.right).offset(-5)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(avatarView.snp.left)
            make.top.equalTo(avatarView.snp.bottom).offset(10)
            make.right.equalTo(contentView.snp.right).offset(-12)
        }
        
        descLabel.snp.makeConstraints { (make) in
            make.left.equalTo(contentView.snp.left).offset(12)
            make.right.equalTo(contentView.snp.right).offset(-12)
            make.top.equalTo(titleLabel.snp.bottom).offset(12)
        }
        
        thumbUpCountLabel.snp.makeConstraints { (make) in
            make.left.equalTo(contentView.snp.left).offset(12)
            make.top.equalTo(descLabel.snp.bottom).offset(12)
        }
        
        commentCountLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(thumbUpCountLabel.snp.bottom)
            make.left.equalTo(thumbUpCountLabel.snp.right).offset(12)
        }
        
        shareButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(thumbUpCountLabel.snp.centerY)
            make.left.equalTo(commentCountLabel.snp.right).offset(12)
        }
        
        
    }

}
